package j02suo;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

class MyRun implements Runnable{
    int count = 100;
    //lock
    Lock lock = new ReentrantLock();
    @Override
    public void run() {
        while (count>0){
            lock.lock();
            String name = Thread.currentThread().getName();
            System.out.println(name+"再卖票："+count);
            count--;
            lock.unlock();
        }
    }
}

public class J1 {
    public static void main(String[] args) {
        MyRun r = new MyRun();
        Thread lin = new Thread(r,"林黛玉");
        Thread xue = new Thread(r,"薛宝钗");

        lin.start();
        xue.start();
    }
}
